import Cookies from 'js-cookie'
const TokenKey = 'token'
export default {
  /** 2.0**/
  getToken: function () {
    return Cookies.get(TokenKey)
  },
  userId: function () {
    let user = JSON.parse(sessionStorage.getItem('userInfo'))
    return user ? user.userId : ''
  },
  getUser: function () {
    let user = JSON.parse(sessionStorage.getItem('userInfo'))
    return user
  },
  getLoginId: function () {
    let user = JSON.parse(sessionStorage.getItem('userInfo'))
    return user.loginId
  },
  getLoginName: function () {
    let user = JSON.parse(sessionStorage.getItem('userInfo'))
    return user ? user.nickName : ''
  },
  /* 1.0 全部都需替换 */
  getAMCompanyId: function () {
    let user = JSON.parse(sessionStorage.getItem('userInfo'))
    return user.PMCompanyId
  },
  getAMProjectId: function () {
    let projectId = JSON.parse(sessionStorage.getItem('remapPMUserNowProjectId'))
    return projectId
  },
  getAMSpaceId: function () {
    let projectId = JSON.parse(sessionStorage.getItem('remapPMUserNowProjectId'))
    return projectId
  },
  /* 用户当前选择的项目对象 */
  getPmProjectObject: function () {
    return JSON.parse(sessionStorage.getItem('remapPMProjectObject'))
  },
  getAMCompanyName: function () {
    let user = JSON.parse(sessionStorage.getItem('remapPMUserInfo'))
    return user.PMCompanyName
  }
}
